<div class="weadmin-body">
    <form class="layui-form" data-form='{:request()->url()}'>

        <div class="layui-form-item" pane>
            <label for="cid" class="layui-form-label">
                <span class="we-red">*</span>歌曲分类
            </label>
            <div class="layui-input-inline">
                <select id="cid" name="type" required="true" lay-verify="required">
                    {volist name="list" id="c"}
                    <option value="{$c.id}">{$c.title}</option>
                    {/volist}
                </select>
            </div>
        </div>

        <div class="layui-form-item">
            <label for="keyword" class="layui-form-label">
                <span class="we-red">*</span>上传录音
            </label>
            <div class="layui-input-inline">
                <button type="button" class="layui-btn" id="audio"><i class="layui-icon"></i>上传音频</button>

                <!--<button type="button" data-upload="{:url('admin/upload/file')}" data-field="pic" data-type="audio"-->
                        <!--value="{$vo.pic|default=''}" class="layui-btn">上传音频</button>-->
                <input type="hidden" name="pic" id="pic" value="{$vo.pic|default=''}" >
            </div>
        </div>

        <div class="layui-form-item layui-col-xs10 layui-col-xs-offset2">
            {if isset($vo.id)}<input type="hidden" name="id" value="{$vo.id}">{/if}
            <button class="layui-btn" lay-submit="">确定</button>
        </div>
    </form>
</div>

<script>
    layui.use('form',function () {
        layui.form.render();
    })
</script>
<script>
    layui.use('upload', function(){
        var $ = layui.jquery
            ,upload = layui.upload;
        upload.render({
            elem: '#audio'
            ,url:"{:url('admin/upload/uploadAudio')}"
            ,accept: 'audio' //音频
            ,size:1024*10//限制文件大小，单位 KB
            ,before:function (obj) {
                layer.load(2,{shade:false});
            }
            ,done: function(res){
                if(res['code']==0){
                    $('#pic').val(res['src']);
                    layer.msg(res.msg);
                }
                layer.closeAll("loading");
            }
        });
    });
</script>